package com.huashi.dealer.modular.controller.api.writeoff;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huashi.dealer.commonEntity.UserWriteoffLog;
import com.huashi.dealer.core.page.PageFactory;
import com.huashi.dealer.core.pojo.CommonResult;
import com.huashi.dealer.modular.business.writeoff.service.WriteoffService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * API核销控制器
 *
 * @author 谭陈强
 * @since 2025-07-30
 */
@Tag(name = "API核销控制器")
@RestController("apiWriteoffController")
@RequestMapping("/api/writeoff")
@Validated
public class WriteoffController {

    @Resource
    private WriteoffService writeoffService;

    /**
     * 核销日志列表
     */
    @GetMapping("/log/lists")
    @Operation(summary = "核销日志列表")
    public CommonResult<Page<UserWriteoffLog>> getWriteoffLogList(@RequestParam(defaultValue = "30") Integer time) {
        try {
            Page<UserWriteoffLog> page = PageFactory.defaultPage();
            Page<UserWriteoffLog> responseParam = writeoffService.getWriteoffLogList(page,time);
            return CommonResult.data(responseParam);
        } catch (Exception e) {
            return CommonResult.error("获取核销日志列表失败：" + e.getMessage());
        }
    }
} 